<html>
<head><meta charset="utf-8"><title>MIR pass ordering · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html">MIR pass ordering</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="148038745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148038745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148038745">(Nov 20 2018 at 13:29)</a>:</h4>
<p>Is it expected that lowering generators to state machines happens <em>after inlining</em>? I'd think MIR generation should be basically done before we do any interesting optimizations, and this lowering seems to conceptually be part of MIR construction.</p>



<a name="148039686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148039686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148039686">(Nov 20 2018 at 13:43)</a>:</h4>
<p>and then we have the deaggregator turning things like </p>
<div class="codehilite"><pre><span></span>_1 = [generator@test.rs:6:25: 15:6] { $state: const 0u32 };
</pre></div>


<p>into</p>
<div class="codehilite"><pre><span></span>(_1.0: u32) = const 0u32;
</pre></div>


<p>which is a problem because now only the first field of the struct actually gets initialized...</p>



<a name="148039736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148039736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148039736">(Nov 20 2018 at 13:44)</a>:</h4>
<p>so the <code>Retag(_1)</code> that got inserted right after this sees uninitialized data</p>



<a name="148040050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148040050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148040050">(Nov 20 2018 at 13:49)</a>:</h4>
<p>hm, actually none of this pass ordering can possibly help</p>



<a name="148040079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148040079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148040079">(Nov 20 2018 at 13:50)</a>:</h4>
<p>would it be reasonable to say that the fields of a generator (all but the first, with the state) are implicitly wrapped in a <code>MaybeUninit</code>?</p>



<a name="148040134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148040134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148040134">(Nov 20 2018 at 13:50)</a>:</h4>
<p>because that seems how things are actually being used...</p>



<a name="148041308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148041308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148041308">(Nov 20 2018 at 14:08)</a>:</h4>
<p>yea, that sounds about like how I understand generators work</p>



<a name="148043260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148043260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148043260">(Nov 20 2018 at 14:40)</a>:</h4>
<blockquote>
<p>Is it expected that lowering generators to state machines happens <em>after inlining</em>? I'd think MIR generation should be basically done before we do any interesting optimizations, and this lowering seems to conceptually be part of MIR construction.</p>
</blockquote>
<p>sounds wrong</p>



<a name="148043279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148043279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148043279">(Nov 20 2018 at 14:40)</a>:</h4>
<blockquote>
<p>would it be reasonable to say that the fields of a generator (all but the first, with the state) are implicitly wrapped in a <code>MaybeUninit</code>?</p>
</blockquote>
<p>but yes, sounds right</p>



<a name="148043433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148043433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148043433">(Nov 20 2018 at 14:43)</a>:</h4>
<p>PR with a workaround/fix for miri: <a href="https://github.com/rust-lang/rust/pull/56100" target="_blank" title="https://github.com/rust-lang/rust/pull/56100">https://github.com/rust-lang/rust/pull/56100</a></p>



<a name="148043670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148043670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148043670">(Nov 20 2018 at 14:47)</a>:</h4>
<p>yeah, I saw it</p>



<a name="148047071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148047071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148047071">(Nov 20 2018 at 15:37)</a>:</h4>
<blockquote>
<p>sounds wrong</p>
</blockquote>
<p>seems like that got introduced with <a href="https://github.com/rust-lang/rust/commit/6e5dacbd5e8aab43cdc4c2f1d4ec66fe0b8d4bed" target="_blank" title="https://github.com/rust-lang/rust/commit/6e5dacbd5e8aab43cdc4c2f1d4ec66fe0b8d4bed">https://github.com/rust-lang/rust/commit/6e5dacbd5e8aab43cdc4c2f1d4ec66fe0b8d4bed</a> by <span class="user-mention" data-user-id="119009">@eddyb</span></p>



<a name="148047078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148047078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148047078">(Nov 20 2018 at 15:37)</a>:</h4>
<p>well, actually before that the pass was <em>even later</em>^^</p>



<a name="148047322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148047322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148047322">(Nov 20 2018 at 15:41)</a>:</h4>
<p>this goes back <em>all the way</em> to the initial commit <a href="https://github.com/rust-lang/rust/commit/d861982ca6a1fa5773373362771aa08b9f732de0#diff-698522bf32a92da4331b4bd3f6ed31c6" target="_blank" title="https://github.com/rust-lang/rust/commit/d861982ca6a1fa5773373362771aa08b9f732de0#diff-698522bf32a92da4331b4bd3f6ed31c6">https://github.com/rust-lang/rust/commit/d861982ca6a1fa5773373362771aa08b9f732de0#diff-698522bf32a92da4331b4bd3f6ed31c6</a> by <span class="user-mention" data-user-id="116466">@Zoxc</span>. Should I, uh, file an issue or so?</p>



<a name="148047777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148047777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148047777">(Nov 20 2018 at 15:47)</a>:</h4>
<p>I moved <code>StateTransform</code> earlier because it has some asserts that break</p>



<a name="148047802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148047802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148047802">(Nov 20 2018 at 15:47)</a>:</h4>
<p>but the intention is to do it as late as possible so we optimize generators</p>



<a name="148047872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148047872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148047872">(Nov 20 2018 at 15:48)</a>:</h4>
<p>including inlining generators</p>



<a name="148047906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148047906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148047906">(Nov 20 2018 at 15:48)</a>:</h4>
<p>I think maybe the asserts should be done early and the <code>StateTransform</code> moved late</p>



<a name="148048830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148048830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148048830">(Nov 20 2018 at 16:01)</a>:</h4>
<blockquote>
<p>including inlining generators</p>
</blockquote>
<p>but can't we better inline them after generator lowering because then they are just normal functions?</p>



<a name="148048837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148048837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148048837">(Nov 20 2018 at 16:01)</a>:</h4>
<p>currently inlining has to know how to special-case generators</p>



<a name="148048860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148048860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148048860">(Nov 20 2018 at 16:01)</a>:</h4>
<p>no, because the normal functions are already state-transformed</p>



<a name="148048878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148048878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148048878">(Nov 20 2018 at 16:01)</a>:</h4>
<p>yes that's exactly what I am saying</p>



<a name="148048925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148048925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148048925">(Nov 20 2018 at 16:02)</a>:</h4>
<p>if you inline after, you can't merge the state</p>



<a name="148048942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148048942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148048942">(Nov 20 2018 at 16:02)</a>:</h4>
<p>"merge"?</p>



<a name="148048951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148048951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148048951">(Nov 20 2018 at 16:02)</a>:</h4>
<p>flatten</p>



<a name="148048958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148048958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148048958">(Nov 20 2018 at 16:02)</a>:</h4>
<p>not have nested state tags</p>



<a name="148048960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148048960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148048960">(Nov 20 2018 at 16:02)</a>:</h4>
<p>oh</p>



<a name="148048964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148048964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148048964">(Nov 20 2018 at 16:02)</a>:</h4>
<p>I see</p>



<a name="148048973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148048973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148048973">(Nov 20 2018 at 16:02)</a>:</h4>
<p>now I don't think inlining is properly set up for this</p>



<a name="148048984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148048984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148048984">(Nov 20 2018 at 16:03)</a>:</h4>
<p>it probably isn't^^</p>



<a name="148049000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049000">(Nov 20 2018 at 16:03)</a>:</h4>
<p>it would need to query the untransformed generators, and <code>optimized_mir</code> is after the transformation</p>



<a name="148049006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049006">(Nov 20 2018 at 16:03)</a>:</h4>
<p>hm. this pretty much means a formal spec for MIR has to spec generators</p>



<a name="148049016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049016">(Nov 20 2018 at 16:03)</a>:</h4>
<p>however, given that borrowck happens before generator lowering, that might be better anyway</p>



<a name="148049018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049018">(Nov 20 2018 at 16:03)</a>:</h4>
<p>that's already true and the surface area is pretty small</p>



<a name="148049032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049032">(Nov 20 2018 at 16:03)</a>:</h4>
<p>yeah, generators have a special relationship with borrowck</p>



<a name="148049086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049086">(Nov 20 2018 at 16:04)</a>:</h4>
<p>that's the best reason for understanding all of this state stuff before LLVM IR</p>



<a name="148049093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049093">(Nov 20 2018 at 16:04)</a>:</h4>
<p>I guess that and guaranteed unboxing</p>



<a name="148049119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049119">(Nov 20 2018 at 16:04)</a>:</h4>
<p>if it happens after borrowck anyway, why care if it is done in MIR or LLVM?</p>



<a name="148049151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049151">(Nov 20 2018 at 16:05)</a>:</h4>
<p>(miri is happy that it's done in MIR though because it means it doesn't have to care^^)</p>



<a name="148049159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049159">(Nov 20 2018 at 16:05)</a>:</h4>
<p>wait I was confusing</p>



<a name="148049193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049193">(Nov 20 2018 at 16:06)</a>:</h4>
<p>what I mean is having any sort of language-level understanding of generators</p>



<a name="148049239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049239">(Nov 20 2018 at 16:06)</a>:</h4>
<p>yeah I agree with that</p>



<a name="148049283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049283">(Nov 20 2018 at 16:06)</a>:</h4>
<p>C++ can leave it all to LLVM because it doesn't need to type-check based on state that's live across yields</p>



<a name="148049286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049286">(Nov 20 2018 at 16:06)</a>:</h4>
<p>or anything like that</p>



<a name="148049321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049321">(Nov 20 2018 at 16:07)</a>:</h4>
<p>hm yeah</p>



<a name="148049344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049344">(Nov 20 2018 at 16:07)</a>:</h4>
<p>I will wonder how to best think about MIR with and without the extra statements I introduced. basically currently we have one syntax for two languages</p>



<a name="148049369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049369">(Nov 20 2018 at 16:07)</a>:</h4>
<p>heh</p>



<a name="148049371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049371">(Nov 20 2018 at 16:07)</a>:</h4>
<p>well, "syntax"</p>



<a name="148049429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049429">(Nov 20 2018 at 16:08)</a>:</h4>
<p>before <code>Retag</code> is added, the semantics implicitly does that stuff, while after introducing these things it is explicit. or so.</p>



<a name="148049476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049476">(Nov 20 2018 at 16:08)</a>:</h4>
<p>there's some danger here of considering the "wrong" one so it might be worth generating them early some day, like, together with initial MIR building? or reflecting this change in semantics in the type somehow? <code>Mir&lt;ImplicitRetag&gt;</code> or so...</p>



<a name="148049516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049516">(Nov 20 2018 at 16:09)</a>:</h4>
<p>there might be an interesting angle here where lowering to a different IR, that maybe loses some of the typedness of MIR, adds this information</p>



<a name="148049547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049547">(Nov 20 2018 at 16:09)</a>:</h4>
<p>so you convert complexity instead of strictly adding</p>



<a name="148049613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049613">(Nov 20 2018 at 16:10)</a>:</h4>
<p>a twist of that is to use the same syntax/datatype for all these IRs</p>



<a name="148049623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049623">(Nov 20 2018 at 16:10)</a>:</h4>
<p>"compilation/lowering to a subset" or so, I saw that somewhere recently</p>



<a name="148049637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049637">(Nov 20 2018 at 16:10)</a>:</h4>
<p>generators actually do that -- they lower from full MIR to MIR\Generators</p>



<a name="148049805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049805">(Nov 20 2018 at 16:13)</a>:</h4>
<p>Cranelift also uses the same IR for the higher-level input and for the heavily transformed version that contains e.g. register allocation, spills, expanded operations when the original didn't have a native encoding on the target, etc., and then it does a straight-forward instruction selection pass on the result, without having to use target-specific instructions for most things</p>



<a name="148049827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049827">(Nov 20 2018 at 16:13)</a>:</h4>
<p>miri is, kinda interestingly, on-the-fly monomorphization and lowering to more primitive ops, and execution of those ops</p>



<a name="148049939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049939">(Nov 20 2018 at 16:15)</a>:</h4>
<p>one could split those up, into something that looks like a codegen backend, and a separate "abstract memory machine"</p>



<a name="148049983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148049983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148049983">(Nov 20 2018 at 16:16)</a>:</h4>
<p>LLVM IR is gnarly, but e.g. Cranelift IR could be emulated on the lower half of miri just fine!</p>



<a name="148050030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148050030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148050030">(Nov 20 2018 at 16:16)</a>:</h4>
<p>/me pokes <span class="user-mention" data-user-id="130125">@Dan Gohman</span></p>



<a name="148056842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148056842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148056842">(Nov 20 2018 at 18:15)</a>:</h4>
<blockquote>
<p>I will wonder how to best think about MIR with and without the extra statements I introduced. basically currently we have one syntax for two languages</p>
</blockquote>
<p>this has been true for a long time, I've been wondering if we want to make this split more explicit</p>



<a name="148056864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148056864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148056864">(Nov 20 2018 at 18:15)</a>:</h4>
<p>(but I'm sort of inclined not to yet)</p>



<a name="148084120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/MIR%20pass%20ordering/near/148084120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/MIR.20pass.20ordering.html#148084120">(Nov 21 2018 at 02:40)</a>:</h4>
<p>Time for HMIR, MMIR, and LMIR</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>